package com.diapoclic.servlet;


import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.diapoclic.entitybean.User;
import com.diapoclic.entitydao.FolderDao;
import com.diapoclic.entitymanager.FolderManager;
import com.diapoclic.entitymanager.UserManager;

public class AddFolderServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)						
											throws IOException, ServletException{
		
		request.getRequestDispatcher("addFolder.jsp").forward(request, response);

		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)						
											throws IOException, ServletException{
		
		
		
		

		//Récupération du nom de l'album a créer
		String nameFolder = (String)request.getParameter("nameFolder");
			
		
		User sessionUser=new User();
		UserManager userMana = new UserManager();
		FolderManager folderMana = new FolderManager();
		////////////////////////////////UTILISATION DES COOKIES///////////////////////////

		sessionUser=userMana.getSessionUser(request.getCookies());

		
		
		try {
			folderMana.getFolderDao().addFolder(nameFolder, 0, sessionUser.getIdUser());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
		
		
		
		request.getRequestDispatcher("album.jsp").forward(request, response);

	}	
}

